from pages.base_page import BasePage


class FollowPage(BasePage):
    first_trend_name = '//*[@resource-id="cool.dingstock.mobile:id/home_fragment_second_rv"]/android.view.ViewGroup[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.view.ViewGroup[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.view.ViewGroup[1]'
    look_more = '//*[@resource-id="cool.dingstock.mobile:id/rv"]/android.widget.LinearLayout[4]/androidx.appcompat.widget.LinearLayoutCompat[1]'
    all_follow = '//*[@resource-id="cool.dingstock.mobile:id/btn_follow_selected"]'
    change_batch = '//*[@text="换一批"]'
    recommend_list_name = 'android.widget.TextView'
    close_recommend_list = '//*[@resource-id="cool.dingstock.mobile:id/common_titlebar_left_icon"]'
    
    def look_more_recommend(self):
        """首页关注tab点击查看更多"""
        self.click_xpath(self.look_more)
        
    def swipe_recommend_list(self):
        """首页关注tab，未关注任何人状态下，滑动推荐关注到最右侧"""
        self.swipe_position((0.917, 0.185), (0.082, 0.182))
        self.swipe_position((0.917, 0.185), (0.082, 0.182))
        
    def is_all_recommend_exist(self):
        """一键关注按钮是否出现"""
        return self.is_xpath_exist(self.all_follow)
    
    def change_recommend_list(self):
        """点击换一批"""
        self.click_xpath(self.change_batch)
    
    def get_first_recommend_name(self):
        """获取推荐关注列表第一个用户名称"""
        return self.get_first_classname_element_text(self.recommend_list_name, 2)
    
    def close_recommend_window(self):
        """关闭推荐列表弹窗"""
        self.click_xpath(self.close_recommend_list)
        
    def get_first_recommend_title_name(self):
        """推荐title第一个用户名"""
        return self.get_first_classname_element_text(self.recommend_list_name, 6)
